from pybotx import Bot, IncomingMessage, IncomingMessageHandlerFunc

from app.resources.strings import CANCEL_COMMAND


async def cancel_creation_middleware(
    message: IncomingMessage, bot: Bot, call_next: IncomingMessageHandlerFunc
) -> None:
    if message.body == CANCEL_COMMAND:
        await message.state.fsm.drop_state()